#ifndef DATABASEMANAGER_H
#define DATABASEMANAGER_H

#include <QSqlDatabase>
#include <QString>
#include <QVariantList>

class DatabaseManager
{
public:
    static DatabaseManager& instance();

    bool initDatabase(const QString& dbPath = "chat.db");
    bool insertUser(const QString& name, const QString& avatar);
    bool insertMessage(int sessionId, int senderId, const QString& content, const QString& time, int type);
    QVariantList queryAllUsers();
    QVariantList queryMessagesBySession(int sessionId);
    bool updateUserName(int userId, const QString& newName);
    bool deleteMessage(int msgId);

private:
    DatabaseManager();
    QSqlDatabase db;
};

#endif // DATABASEMANAGER_H